package org.testframe;

/**
 * 时间等待器
 *
 * @author 丁常磊
 * @date 2023/11/17 13:12
 */

public class TimeWaiteBuilder {

    private final Long maxWaite;

    private final RandomNumberGenerator randomNumberGenerator;

    private final long unit;

    public TimeWaiteBuilder(Long maxWaite, RandomNumberGenerator randomNumberGenerator,long unit) {
        this.maxWaite = maxWaite;
        this.randomNumberGenerator = randomNumberGenerator;
        this.unit = unit;
    }

    public TimeWaite create() {
        if (randomNumberGenerator == null) {
            return new TimeWaite(maxWaite*unit);
        } else {
            return new TimeWaite(randomNumberGenerator.genLong() * unit);
        }
    }

}
